]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
layout: Ensure that the hotCorners array is always indexable by monitor number
authorJasper St. Pierre <jstpierre@mecheye.net>
Tue, 19 Mar 2013 19:50:16 +0000 (15:50 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Tue, 23 Apr 2013 23:14:01 +0000 (19:14 -0400)
messageTray relies on indexing the hot corners array by monitor number,
so we should make this a guarantee.

https://bugzilla.gnome.org/show_bug.cgi?id=698513

js/ui/layout.js

index ebc9a1dcdd33e1e22619304026f3fc76a160eda5..a7356a0248cf9bf15d6e0dc2ff1a82cc2942d679 100644 (file)
@@ -283,8 +283,10 @@ const LayoutManager = new Lang.Class({
 
     _updateHotCorners: function() {
         // destroy old hot corners
-        for (let i = 0; i < this.hotCorners.length; i++)
-            this.hotCorners[i].destroy();
+        this.hotCorners.forEach(function(corner) {
+            if (corner)
+                corner.destroy();
+        });
         this.hotCorners = [];
 
         let size = this.panelBox.height;
@@ -295,9 +297,9 @@ const LayoutManager = new Lang.Class({
             let cornerX = this._rtl ? monitor.x + monitor.width : monitor.x;
             let cornerY = monitor.y;
 
-            if (i != this.primaryIndex) {
-                let haveTopLeftCorner = true;
+            let haveTopLeftCorner = true;
 
+            if (i != this.primaryIndex) {
                 // Check if we have a top left (right for RTL) corner.
                 // I.e. if there is no monitor directly above or to the left(right)
                 let besideX = this._rtl ? monitor.x + 1 : cornerX - 1;
@@ -324,14 +326,15 @@ const LayoutManager = new Lang.Class({
                         break;
                     }
                 }
-
-                if (!haveTopLeftCorner)
-                    continue;
             }
 
-            let corner = new HotCorner(this, monitor, cornerX, cornerY);
-            corner.setBarrierSize(size);
-            this.hotCorners.push(corner);
+            if (haveTopLeftCorner) {
+                let corner = new HotCorner(this, monitor, cornerX, cornerY);
+                corner.setBarrierSize(size);
+                this.hotCorners.push(corner);
+            } else {
+                this.hotCorners.push(null);
+            }
         }
 
         this.emit('hot-corners-changed');
@@ -408,7 +411,8 @@ const LayoutManager = new Lang.Class({
 
         let size = this.panelBox.height;
         this.hotCorners.forEach(function(corner) {
-            corner.setBarrierSize(size);
+            if (corner)
+                corner.setBarrierSize(size);
         });
     },